package com.tools;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigManager {
    private static ConfigManager configManager = new ConfigManager(); ;
    private static Properties properties;

    private ConfigManager(){
        String configFlic = "database.properties";
        properties = new Properties();
        InputStream is = ConfigManager.class.getClassLoader().getResourceAsStream(configFlic);
        try{
            properties.load(is);
            is.close();
        }catch (IOException e){
            e.printStackTrace();
        }
    }
    public String getValue(String key){
        return properties.getProperty(key);
    }

    public static synchronized ConfigManager getInstance(){
        if(configManager == null){
            configManager = new ConfigManager();
        }
        return  configManager;
    }
}